﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataCenter_DataBase;

namespace DataCenter.Models
{
    public class ApiDataBase
    {
        private DataCenterEntities m_Db;
        public DataCenterEntities _Db
        {
            get
            {
                if (m_Db == null)
                {
                    m_Db = new DataCenterEntities();
                }
                return m_Db;
            }
        }

        public tbl_weixin_user GetWeiXinUserByOpenId(string OpenId)
        {
            List<tbl_weixin_user> items = _Db.tbl_weixin_user.Where(item => item.openid == OpenId).ToList();
            if (items.Count > 0)
            {
                return items[0];
            }
            else
            {
                return null;
            }
        }

        public tbl_client GetClientByCode(string Client_Code)
        {
            List<tbl_client> items = _Db.tbl_client.Where(item => item.client_code == Client_Code).ToList();
            if (items.Count > 0)
            {
                return items[0];
            }
            else
            {
                return null;
            }
        }

        public tbl_sys_config GetSysConfig()
        {
            tbl_sys_config configItem = _Db.tbl_sys_config.First();
            return configItem;
        }

    }
}